﻿<UserControl x:Class="UML_Creator.View.ClassDiagram"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:u="clr-namespace:UML_Creator.ViewModel"
             mc:Ignorable="d" 
             Background="White"
             >

    <Canvas>
        <Grid Canvas.Top="{Binding Y}" Canvas.Left="{Binding X}" 
             u:SizeObserver.Observe="True"
             u:SizeObserver.ObservedWidth="{Binding Width, Mode=OneWayToSource}"
             u:SizeObserver.ObservedHeight="{Binding Height, Mode=OneWayToSource}">

            <!-- <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions> -->
        <StackPanel Canvas.Top="{Binding Y}" Canvas.Left="{Binding X}">
            <TextBox Height="23"  TextWrapping="Wrap" Text="{Binding ClassName}" BorderThickness="1,1,1,0" Foreground="Black" FontWeight="Bold" BorderBrush="{Binding Colour}" Opacity="{Binding Opacity}" Focusable="False" IsTabStop="False" IsEnabled="False">
            </TextBox>
            <TextBox  TextWrapping="Wrap" Text="{Binding ClassAttributes}" IsInactiveSelectionHighlightEnabled="True" IsManipulationEnabled="True" BorderThickness="1,1,1,0" Foreground="Black" AcceptsReturn="True" IsReadOnlyCaretVisible="True" Focusable="False" BorderBrush="{Binding Colour}" Opacity="{Binding Opacity}" IsEnabled="False"/>
            <TextBox  TextWrapping="Wrap" Text="{Binding ClassMethods}" IsInactiveSelectionHighlightEnabled="True" IsManipulationEnabled="True" BorderThickness="1" Foreground="Black" AcceptsReturn="True" BorderBrush="{Binding Colour}" Opacity="{Binding Opacity}" IsEnabled="False"/>
        </StackPanel>
        </Grid>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
                <cmd:EventToCommand Command="{Binding DataContext.MouseDoubleClickNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseDown">
                <cmd:EventToCommand Command="{Binding DataContext.MouseDownNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseMove">
                <cmd:EventToCommand Command="{Binding DataContext.MouseMoveNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseUp">
                <cmd:EventToCommand Command="{Binding DataContext.MouseUpNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>

        </i:Interaction.Triggers>
        
    </Canvas>
</UserControl>
